# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=libusbmuxd
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.0.1
pkgrel=1
pkgdesc='A client library to multiplex connections from and to iOS devices (mingw-w64)'
arch=('any')
url='https://www.libimobiledevice.org/'
license=('GPL2+')
options=('staticlibs')
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/libimobiledevice/libusbmuxd/archive/${pkgver}.tar.gz")
depends=("${MINGW_PACKAGE_PREFIX}-libplist")
sha256sums=('f93faf3b3a73e283646f4d62b3421aeccf58142266b0eb22b2b13dd4b2362eb8')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd "${srcdir}"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  make check
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
